<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>初始密码修改</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link th:href="@{../static/layuiadmin/layui/css/layui.css}" rel="stylesheet">
    <link th:href="@{../static/layuiadmin/style/admin.css}" rel="stylesheet">
</head>
<body>


<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改初始密码</div>
                <div class="layui-card-body" pad15>

                    <div class="layui-form" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">当前密码<i style="color: red">*</i></label>
                            <div class="layui-input-inline">
                                <input type="password" name="oldPassword" id="oldPassword"
                                       lay-verType="tips" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码<i style="color: red">*</i></label>
                            <div class="layui-input-inline">
                                <input type="password" name="newpassword"  autocomplete="off" id="newPassword" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">6到12个字符，必须包含英文字母</div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit  id="update">确认修改</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>


<script th:src="@{/static/layuiadmin/layui/layui.js}" rel="stylesheet"></script>
<script>
    layui.config({
        base: '../static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set'], function () {

        var $ = layui.$
            , setter = layui.setter
            , admin = layui.admin
            , form = layui.form
            , router = layui.router()
            , search = router.search;

        form.render();

        //调用后台登录
        $(document).on('click', '#update', function () {
            event.preventDefault()

            var userInfo = {
                oldPassword: $("#oldPassword").val(),
                newPassword: $("#newPassword").val(),
            }
            $.post("./password", userInfo, function (res) {
                // console.info("/ams/password+++++++++++++" + res);

                 if (res.code == 500) {
                    layui.use('layer', function () {
                        var layer = layui.layer;
                        layer.msg(res.message, {icon: 5,time:1000})
                    })
                }else{
                     var layer = layui.layer;
                     layer.msg('修改成功', {
                             offset: '15px'
                             , icon: 1
                             , time: 1000
                         }, function () {
                         location.href = "./loginIndex"; //跳转到登入页
                     });
                 }

            });

        });
    });
</script>
</body>
</html>